package com.zyf.utils;

import java.lang.reflect.Array;
import java.util.Iterator;
import java.util.List;

public class ListUtil {
    public static <E> boolean isEmpty(List<E> list) {
        return list == null || list.size() == 0;
    }

    public static <E> E[] toArray(List<E> list) {
        if (isEmpty(list)) {
            return null;
        } else {
            E notNullItem = null;
            boolean find = false;
            Iterator var3 = list.iterator();
            while (var3.hasNext()) {
                E e = (E)var3.next();
                if (find) {
                    break;
                }

                if (e != null) {
                    notNullItem = e;
                    find = true;
                }
            }

            E[] result = null;
            if (notNullItem != null) {
                result = (E[]) ((E[]) Array.newInstance(notNullItem.getClass(), list.size()));
                result = list.toArray(result);
            }
            return result;
        }
    }
}
